﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Organization.API.Application.Command.CottageCommand;
using S.Organization.API.Application.Command.SheepFarmCommand;
using S.Organization.API.Application.Command.SupplierCommand;

namespace S.Organization.API.Controllers
{
    /// <summary>
    /// 供应商控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierController : ControllerBase
    {

        private readonly IMediator _mediator;

        public SupplierController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> HandleAddSupplier(AddSupplierCommand request, CancellationToken cancellationToken)
        {
            return Ok(await _mediator.Send(request));
        }


        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> HandleUpSupplier(UpdSupplierCommand request, CancellationToken cancellationToken)
        {
            return Ok(await _mediator.Send(request));
        }



        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleDelSupplier([FromQuery] DelSupplierCommand request, CancellationToken cancellationToken)
        {
            return Ok(await _mediator.Send(request));
        }



    }
}
